package com.service;

import static com.def.GenericDef.E_BIS_LAYOT;
import static com.def.GenericDef.E_BIS_MDL_DEF;
import static com.def.GenericDef.E_BIS_TOOL;
import static com.def.GenericDef.E_READ_NOT_FOUND;
import static com.def.GenericDef.E_RET_WO;
import static com.def.GenericDef.E_XPINQBOX_INVALID_INPUT;
import static com.def.GenericDef.E_XPINQLOT_ERROR_LAYOT_CATE;
import static com.def.GenericDef.E_XPINQLOT_ERROR_TOOL_ID_OR_BAY_ID;
import static com.def.GenericDef.E_XPINQLOT_OTHER_ERROR;
import static com.def.GenericDef.LOT_SPLIT_0;
import static com.def.GenericDef.PATH_TYPE_REWK;
import static com.def.GenericDef.PROC_WAIT;
import static com.def.GenericDef.RETURN_CODE_OK;
import static com.def.GenericDef.RETURN_CODE_SET_ERROR;
import static com.def.GenericDef.RETURN_CODE_UNKNOWN;
import static com.def.GenericDef.RETURN_MESG_OK;
import static com.def.GenericDef.STRING_SERIAL_TYPE_LOT;
import static com.def.GenericDef.TRX_OUT;
import static com.def.GenericDef._NO;
import static com.def.GenericDef._NORMAL;
import static com.def.GenericDef._YES;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import com.dao.IBisLayotDao;
import com.dao.IBisMdlDefDao;
import com.dao.IBisPathiDao;
import com.dao.IBisToolDao;
import com.dao.IRetPrdInfoDao;
import com.dao.IRetPrdLotDao;
import com.dao.IRetWODao;
import com.icim.service.ICIMBaseService;
import com.mapKeyVal.key.StatBoxOpeBnkKey;
import com.mapKeyVal.key.StatBoxOpeBnkWoKey;
import com.model.Bis_layot;
import com.model.Bis_mdl_def;
import com.model.Bis_pathi;
import com.model.Bis_pathiId;
import com.model.Bis_tool;
import com.model.Ret_prd_info;
import com.model.Ret_prd_lot;
import com.model.Ret_prd_lotId;
import com.model.Ret_wo;
import com.tx.Xpcrtno.XpcrtnoI;
import com.tx.Xpcrtno.XpcrtnoO;
import com.tx.Xpinqlot.XpinqlotI;
import com.tx.Xpinqlot.XpinqlotO;
import com.tx.Xpinqlot.XpinqlotOA;
import com.tx.Xpinqlot.XpinqlotOB;
import com.util.MqOpe;
import com.util.Util;

@Scope("prototype")
@Service("XpinqlotService")
public class XpinqlotService extends ICIMBaseService{
	private static Logger logger = Logger.getLogger(XpinqlotService.class);
	private static String TX_NAME = "XPINQLOT";

	private XpinqlotI inTrx;
	private XpinqlotO outTrx;

	@Autowired
	private IRetPrdInfoDao retPrdInfoDao;

	@Autowired
	private IRetPrdLotDao retPrdLotDao;

	@Autowired
	private IRetWODao retWoDao;

	@Autowired
	private IBisMdlDefDao bisMdlDefDao;

	@Autowired
	private IBisLayotDao bisLayotDao;

	@Autowired
	private IBisToolDao bisToolDao;
	
	@Autowired
	private XpcrtnoService xpcrtnoService;
	
	@Autowired
	private IBisPathiDao bisPathiDao;

	private String gszMsgBuf = "";
	private Timestamp gEvtTimestamp;
	private Double gEvtTimeD;
	
	public String subMainProc(String strInMsg) {
		long rtnCode = _NORMAL;
		gszMsgBuf = "";
		gEvtTimestamp = Util.getCurrentTimestamp();
		gEvtTimeD = Util.getDoubleTime();
		String outMsg = "";
		inTrx = new XpinqlotI();
		outTrx = new XpinqlotO();
		outTrx.setTrx_id(TX_NAME);
		outTrx.setType_id(TRX_OUT);
		outTrx.setRtn_code(String.valueOf(RETURN_CODE_SET_ERROR));

		MqOpe mqOpe = new MqOpe();

		try {
			inTrx = (XpinqlotI) mqOpe.inStr2Obj(strInMsg, inTrx);
			logger.info("InTrx is " + strInMsg);

			rtnCode = subMainProc2(inTrx.getAction_flg().toCharArray()[0]);
			if (rtnCode != _NORMAL) {
				outTrx.setRtn_code(String.valueOf(rtnCode));
				outTrx.setRtn_mesg(gszMsgBuf);
				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			} else {
				outTrx.setRtn_code(String.valueOf(RETURN_CODE_OK));
				outTrx.setRtn_mesg(RETURN_MESG_OK);
				retPrdInfoDao.flushCurSession();
			}
		} catch (Exception ex) {
			outTrx.setRtn_mesg(ex.toString());
			outTrx.setRtn_code(RETURN_CODE_UNKNOWN);
			logger.error(Util.stackTraceToString(ex));
			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
		} finally {
			outMsg = mqOpe.obj2Str(outTrx);
			logger.info(outMsg);
		}
		return outMsg;
	}

	private long subMainProc2(char actionType) {
		long rtnCode = _NORMAL;

		switch (actionType) {
		case 'Q': {
			rtnCode = getLotInfo();
			break;
		}
		case 'L': {
			rtnCode = getPrdListInfo();
			break;
		}
		case 'C': {
			rtnCode = creatLotId();
			break;
		}
		case 'M': {
			rtnCode = getPrdListInfo();
			if(rtnCode != 0){
				break;
			}
			rtnCode = getSummaryInfoForLot();
			break;
		}
		default: {
			gszMsgBuf = "Invalide type input: [" + actionType + "]";
			return E_XPINQBOX_INVALID_INPUT;
		}
		}
		return rtnCode;
	}
	

	private long getLotInfo() {
		return 0;
	}

	private long getPrdListInfo() {

		long lRc = _NORMAL;
		List<Ret_prd_info> retPrdInfoList = null;
		List<XpinqlotOA> oaryList = new ArrayList<XpinqlotOA>();
		if(inTrx.getProc_flg() == null){
			String hql = " FROM Ret_prd_info where lot_id=:lot_id";
			try {
				Query query = retPrdInfoDao.getCrSession().createQuery(hql);
				query.setString("lot_id", inTrx.getLot_id());
				retPrdInfoList = query.list();
			} catch (Exception ex) {
				lRc = E_XPINQLOT_OTHER_ERROR;
				logger.error("read RET_PRD_INFO ERROR:" + ex.getMessage());
				logger.error(Util.stackTraceToString(ex));
			}
		}else if(inTrx.getProc_flg().equals("JB")){
			String hql = " FROM Ret_prd_info where fst_lot_id_fk=:fst_lot_id";
			try {
				Query query = retPrdInfoDao.getCrSession().createQuery(hql);
				query.setString("fst_lot_id", inTrx.getLot_id());
				retPrdInfoList = query.list();
			} catch (Exception ex) {
				lRc = E_XPINQLOT_OTHER_ERROR;
				logger.error("read RET_PRD_INFO ERROR:" + ex.getMessage());
				logger.error(Util.stackTraceToString(ex));
			}
		}else{
			String hql = " FROM Ret_prd_info where snd_lot_id_fk=:snd_lot_id";
			try {
				Query query = retPrdInfoDao.getCrSession().createQuery(hql);
				query.setString("snd_lot_id", inTrx.getLot_id());
				retPrdInfoList = query.list();
			} catch (Exception ex) {
				lRc = E_XPINQLOT_OTHER_ERROR;
				logger.error("read RET_PRD_INFO ERROR:" + ex.getMessage());
				logger.error(Util.stackTraceToString(ex));
			}
		}
		

		for (Ret_prd_info ret_prd_info : retPrdInfoList) {
			XpinqlotOA oary = new XpinqlotOA();
			oary.setPrd_seq_id(ret_prd_info.getPrd_seq_id());
			oary.setFab_sn(ret_prd_info.getFab_sn());
			oary.setSlot_no(ret_prd_info.getSlot_no());
			oary.setPrd_stat(ret_prd_info.getPrd_stat());
			oary.setBox_id_fk(ret_prd_info.getBox_id_fk());
			oary.setPrd_grade(ret_prd_info.getPrd_grade());
			String pathId = PROC_WAIT.equals(ret_prd_info.getPrd_stat()) ? ret_prd_info.getNx_path_id_fk() : ret_prd_info.getCr_path_id_fk();
			String pathVer = PROC_WAIT.equals(ret_prd_info.getPrd_stat()) ? ret_prd_info.getNx_path_ver_fk() : ret_prd_info.getCr_path_ver_fk();
			//增加返工品标识
//			if(!Util.isSpaceCheck(ret_prd_info.getOqc_skip_flg())){
//				oary.setOqc_skip_flg(ret_prd_info.getOqc_skip_flg());
//			}
			Bis_pathiId id = new Bis_pathiId();
			id.setPath_id(pathId);
			id.setPath_ver(pathVer);
			Bis_pathi bis_pathi = bisPathiDao.get(id);
			if(bis_pathi !=null){
				if(bis_pathi.getPath_cate().equals(PATH_TYPE_REWK)){
					oary.setOqc_skip_flg(_YES);
				}else{
					oary.setOqc_skip_flg(_NO);
				}
			}
			oary.setBnk_flg(ret_prd_info.getBnk_flg());
			if (ret_prd_info.getPrd_stat().equals("INPR")) {
				oary.setCr_ope_id(ret_prd_info.getCr_ope_id_fk());
				oary.setCr_ope_no(ret_prd_info.getCr_ope_no_fk());
				oary.setCr_ope_ver(ret_prd_info.getCr_ope_ver_fk());
				oary.setCr_path_id(ret_prd_info.getCr_path_id_fk());
				oary.setCr_path_ver(ret_prd_info.getCr_path_ver_fk());
				oary.setCr_proc_id_fk(ret_prd_info.getCr_proc_id_fk());
			} else {
				oary.setCr_ope_id(ret_prd_info.getNx_ope_id_fk());
				oary.setCr_ope_no(ret_prd_info.getNx_ope_no_fk());
				oary.setCr_ope_ver(ret_prd_info.getNx_ope_ver_fk());
				oary.setCr_path_id(ret_prd_info.getNx_path_id_fk());
				oary.setCr_path_ver(ret_prd_info.getNx_path_ver_fk());
				oary.setCr_proc_id_fk(ret_prd_info.getNx_proc_id_fk());
			}
			oary.setTool_id_fk(ret_prd_info.getTool_id_fk());
			oary.setLot_id_fk(ret_prd_info.getLot_id());
			oary.setMdl_id_fk(ret_prd_info.getMdl_id_fk());
			oary.setSo_id_fk(ret_prd_info.getSo_id_fk());
			oary.setWo_id_fk(ret_prd_info.getWo_id_fk());
			oary.setMtrl_box_id(ret_prd_info.getMtrl_box_id_fk());
			oaryList.add(oary);
		}
		outTrx.setRtn_code(RETURN_CODE_OK);
		outTrx.setRtn_mesg(RETURN_MESG_OK);
		outTrx.setOary(oaryList);
		outTrx.setSht_cnt(oaryList.size());

		return lRc;

	}
	private long creatLotId() {
		long lRc = _NORMAL;
		MqOpe mqOpe = new MqOpe();
		String lot_id = "L";
		String key_id="L";
		String lot_data = "";
		String lot_banbie = "";
		
		//获取设备信息
		Bis_tool bis_tool = bisToolDao.get(inTrx.getTool_id());
		if (bis_tool == null) {
			gszMsgBuf = "未找到设备代码:[" + inTrx.getTool_id() + "]!";
			return E_BIS_TOOL + E_READ_NOT_FOUND;
		}
		//根据设备区域代码，确定批次第一码厂别。F代表1厂；S代表2厂；T代表3厂
//		if (bis_tool.getBay_id().equals("F2")) {
//			lot_id = "S";
//			key_id = "S"; 
//		} else if (bis_tool.getBay_id().equals("M3")) {
//			lot_id = "T";
//			key_id = "T";
//		} else {
//			gszMsgBuf = "请检查设备代码:[" + inTrx.getTool_id() + "]是否为来料检设备！并且设备区域代码是否为F2或M3";
//			return E_XPINQLOT_ERROR_TOOL_ID_OR_BAY_ID;
//		}
		//获取工单信息
		Ret_wo ret_wo = retWoDao.get(inTrx.getWo_id());
		if (ret_wo == null) {
			gszMsgBuf = "未找到工单代码:[" + inTrx.getWo_id() + "]!";
			return E_RET_WO + E_READ_NOT_FOUND;
		}
		//获取产品信息
		Bis_mdl_def bis_mdl_def = bisMdlDefDao.get(ret_wo.getMdl_id_fk());
		if (bis_mdl_def == null) {
			gszMsgBuf = "未找到产品代码:[" + ret_wo.getMdl_id_fk() + "]!";
			return E_BIS_MDL_DEF + E_READ_NOT_FOUND;
		}
		//获取产品layout信息
		Bis_layot bis_layot = (Bis_layot) bisLayotDao.get(bis_mdl_def.getLayot_id_fk());
		if (bis_layot == null) {
			gszMsgBuf = "未找到Layot代码:[" + bis_mdl_def.getLayot_id_fk() + "]!";
			return E_BIS_LAYOT + E_READ_NOT_FOUND;
	    }
	   //根据产品layout的版式规格确定批次第二码。版式规格为L，第二码为1；S，第二码为2.
	    if(bis_layot.getLayot_cate().equals("L")){
	    	lot_id = lot_id + "1";
	    	key_id = key_id + "1";
	    }else if(bis_layot.getLayot_cate().equals("S")){
	    	lot_id = lot_id + "2";
	    	key_id = key_id + "2";
	    }else{
			gszMsgBuf = "请检查Layot代码:[" + bis_mdl_def.getLayot_id_fk() + "]的版式规格是否为L或S";
			return E_XPINQLOT_ERROR_LAYOT_CATE;
	    }
	    //获取时间，确定批次第3至8码年月日
	    lot_data = Util.getLotData().substring(2,8);
	    lot_id = lot_id + lot_data;
	    key_id = key_id + lot_data;
		//根据目标厚度，确定批次第9至12码产品厚度
	    lot_id = lot_id + Util.getThickFormat(ret_wo.getTo_thickness());
		//根据系统时间，确定批次第13码白夜班
	    lot_banbie = Util.getShiftType();
	    lot_id = lot_id + lot_banbie;
	    key_id = key_id + lot_banbie;
		XpcrtnoI xpcrtNOI = new XpcrtnoI();
		xpcrtNOI.setType("XPCRTNO");
		xpcrtNOI.setTrx_id("I");
		xpcrtNOI.setKey_id(key_id);
		xpcrtNOI.setType(STRING_SERIAL_TYPE_LOT);
		xpcrtNOI.setAction_flg("L");
		String strInMsg = mqOpe.obj2Str(xpcrtNOI);
		String strOutMsg = xpcrtnoService.subMainProc(strInMsg);
		XpcrtnoO xpcrtNoO = new XpcrtnoO();
		xpcrtNoO = (XpcrtnoO) mqOpe.inStr2Obj(strOutMsg, xpcrtNoO);
		if (!xpcrtNoO.getRtn_code().equals(RETURN_CODE_OK)) {
			gszMsgBuf = xpcrtNoO.getRtn_mesg();
			return Integer.valueOf(xpcrtNoO.getRtn_code());
		} else {
			lot_id = lot_id + xpcrtNoO.getSerial_no();
		}

		outTrx.setLot_id(lot_id);
		return lRc;
	}
	
	/**
	 * Add lot info
	 * 
	 * @return
	 */
	private long addLotInfo(String lot_id,Integer prd_qty) {
		Ret_prd_lot ret_prd_lot = new Ret_prd_lot();
		Ret_prd_lotId ret_prd_lotId = new Ret_prd_lotId();
		ret_prd_lotId.setLot_id(lot_id);
		ret_prd_lotId.setLot_splt_id(LOT_SPLIT_0);

		ret_prd_lot = retPrdLotDao.get(ret_prd_lotId);
		if (null != ret_prd_lot) {
			ret_prd_lot.setLot_qty(prd_qty + ret_prd_lot.getLot_qty());
			ret_prd_lot.setEvt_usr(inTrx.getEvt_usr());
			ret_prd_lot.setEvt_timestamp(gEvtTimestamp);
			ret_prd_lot.setEvt_time_d(gEvtTimeD);
			retPrdLotDao.update(ret_prd_lot);
		} else {
			ret_prd_lot = new Ret_prd_lot();
			ret_prd_lotId = new Ret_prd_lotId();
			ret_prd_lotId.setLot_id(lot_id);
			ret_prd_lotId.setLot_splt_id(LOT_SPLIT_0);
			ret_prd_lot.setId(ret_prd_lotId);
			ret_prd_lot.setLot_stat(PROC_WAIT);
			ret_prd_lot.setLot_qty(prd_qty);
			ret_prd_lot.setEvt_usr(inTrx.getEvt_usr());
			ret_prd_lot.setEvt_timestamp(gEvtTimestamp);
			ret_prd_lot.setEvt_time_d(gEvtTimeD);
			ret_prd_lot.setStb_timestamp(gEvtTimestamp);

			retPrdLotDao.save(ret_prd_lot);
		}

		return _NORMAL;
	}

	private long getSummaryInfoForLot() {
		String lotId = inTrx.getLot_id();
		int lotTotalCnt=0, finishedCnt =0, unFinishedCnt  = 0;
		int logofCnt;
		String opeId,prdStat,cusId="",soId="",woId="",mdlId="",oqc_skip_flg = " ";
//		Map<CompPrd, Integer> compPrdMap = new HashMap<CompPrd, Integer>();
		Map<StatBoxOpeBnkKey,Integer> wipMap = new HashMap<StatBoxOpeBnkKey,Integer>(); 
		Map<StatBoxOpeBnkKey, String> oqcskpflgMap = new HashMap<StatBoxOpeBnkKey, String>();
		Map<String,Integer> opeUnLogofMap = new HashMap<String,Integer>();
		Map<String,Integer> opeLogofMap = new HashMap<String,Integer>();
//		String hql = "FROM Ret_prd_lot WHERE lot_id = :lot_id";
//		Query query = retPrdLotDao.getCrSession().createQuery(hql);
//		query.setString("lot_id", lotId);
//		Ret_prd_lot retPrdLot = (Ret_prd_lot) query.uniqueResult();
//		if (retPrdLot == null) {
//			gszMsgBuf = "查不到批次信息";
//			return 1;
//		}
		String hql = "";
		if(inTrx.getProc_flg().equals("JB")){
			hql = "FROM Ret_prd_info WHERE fst_lot_id_fk =? ";
		}else{
			hql = "FROM Ret_prd_info WHERE snd_lot_id_fk =? ";
		}
		List<Ret_prd_info> retPrdInfoList = retPrdInfoDao.list(hql,lotId);
		if(retPrdInfoList.isEmpty()){
			gszMsgBuf = "查不到批次信息";
			return 1;
		}
		woId = retPrdInfoList.get(0).getWo_id_fk();
		if(StringUtils.isEmpty(woId)){
			gszMsgBuf = "玻璃["+retPrdInfoList.get(0).getPrd_seq_id() + "]的工单信息为空,错误";
			return 2;
		}
		Ret_wo ret_wo = retWoDao.get(woId);
		if (ret_wo == null) {
			gszMsgBuf = "找不到内部订单信息";
			return 3;
		}
		cusId = ret_wo.getCus_id_fk(); 
		soId = ret_wo.getSo_id();
		mdlId = ret_wo.getMdl_id_fk();
			
		for (Ret_prd_info retPrdInfo : retPrdInfoList) {
			//统计批次总数量,成品数量,半成品数量
			if("SHIP".equals(retPrdInfo.getPrd_stat()) && "1".equals(retPrdInfo.getBnk_flg())){
				finishedCnt ++;
			}else{
				unFinishedCnt++;
			}
			lotTotalCnt++;
			//统计在制数量
				//统计INPR产品
			opeId = "INPR".equals(retPrdInfo.getPrd_stat()) ? retPrdInfo.getCr_ope_id_fk(): retPrdInfo.getNx_ope_id_fk();
			prdStat = retPrdInfo.getPrd_stat();
			String pathId = PROC_WAIT.equals(retPrdInfo.getPrd_stat()) ? retPrdInfo.getNx_path_id_fk() : retPrdInfo.getCr_path_id_fk();
			String pathVer = PROC_WAIT.equals(retPrdInfo.getPrd_stat()) ? retPrdInfo.getNx_path_ver_fk() : retPrdInfo.getCr_path_ver_fk();
			StatBoxOpeBnkKey wipKey = new StatBoxOpeBnkKey(prdStat,opeId ,retPrdInfo.getBox_id_fk(),retPrdInfo.getBnk_flg());
			
			if(wipMap.containsKey(wipKey)){
				wipMap.put(wipKey,wipMap.get(wipKey)+1);
			}else{
				wipMap.put(wipKey, 1);
			}
			//增加返工品标识
			Bis_pathiId id = new Bis_pathiId();
			id.setPath_id(pathId);
			id.setPath_ver(pathVer);
			Bis_pathi bis_pathi = bisPathiDao.get(id);
			if(bis_pathi !=null){
				if(bis_pathi.getPath_cate().equals(PATH_TYPE_REWK)){
					oqc_skip_flg = "Y";
				}else{
					oqc_skip_flg = "N";
				}
			}
//			if(!Util.isSpaceCheck(retPrdInfo.getOqc_skip_flg())){
//				oqc_skip_flg = retPrdInfo.getOqc_skip_flg();
//			}
			if (oqcskpflgMap.containsKey(wipKey)) {
				if ( oqc_skip_flg.equals("Y") ) {
					oqcskpflgMap.put(wipKey, oqc_skip_flg);
				}else if (oqc_skip_flg.equals("N") && oqcskpflgMap.get(wipKey).equals(" ")) {
					oqcskpflgMap.put(wipKey, oqc_skip_flg);
				};
			} else {
				oqcskpflgMap.put(wipKey, oqc_skip_flg);
			}
			
			//统计站点数量
			if(opeUnLogofMap.containsKey(opeId)){
				opeUnLogofMap.put(opeId, opeUnLogofMap.get(opeId)+1);
			}else{
				opeUnLogofMap.put(opeId, 1);
			}
			
			
		}
		Iterator iter = opeUnLogofMap.entrySet().iterator();
		while(iter.hasNext()){
			Entry<String,Integer> entry = (Entry<String, Integer>) iter.next();
			logger.info(entry.getKey()+":"+ entry.getValue());
			//统计该站已完成数量 TODO:HIS_RET_PRD_INFO表恢复正常前，不能使用次查询
//			hql = "select count(*) FROM His_ret_prd_info where lot_id = '"+lotId+"' AND cr_ope_id_fk='"+entry.getKey() + "' AND evt_cate='LOGF'";
//			long llogofCnt =(Long) retPrdInfoDao.getCrSession().createQuery(hql).uniqueResult();
//			logofCnt = (int) llogofCnt;
//			opeLogofMap.put(entry.getKey(), logofCnt);
		}
		iter = wipMap.entrySet().iterator();
		List<XpinqlotOB> oaryBList = new ArrayList<XpinqlotOB>();
		while(iter.hasNext()){
			Entry<StatBoxOpeBnkKey,Integer> wipEntry = (Entry<StatBoxOpeBnkKey, Integer>) iter.next();
			StatBoxOpeBnkKey wipPrd = wipEntry.getKey();
			XpinqlotOB oaryB = new XpinqlotOB();
			List<Ret_prd_info> prdInfoList1 = new ArrayList<Ret_prd_info>();
			oaryB.setBox_id_fk(wipPrd.getBox_id());
			oaryB.setCus_id(cusId);
			oaryB.setOpe_id(wipPrd.getOpe_id());
			oaryB.setPrd_stat(wipPrd.getPrd_stat());
			oaryB.setBnk_flg(wipPrd.getBnk_flg());
			oaryB.setSo_id(soId);
			oaryB.setWo_id(woId);
			oaryB.setMdl_id(mdlId);
			oaryB.setLot_total_cnt(lotTotalCnt);
			oaryB.setWip_cnt(wipEntry.getValue());
			oaryB.setFinished_cnt(finishedCnt);
			oaryB.setUnfinished_cnt(unFinishedCnt);
			oaryB.setOpe_logof_cnt(opeLogofMap.get(wipPrd.getOpe_id()));
			oaryB.setOpe_unlogof_cnt(opeUnLogofMap.get(wipPrd.getOpe_id()));
			oaryB.setOqc_skip_flg(oqcskpflgMap.get(wipPrd));
			if(!("").equals(wipPrd.getBox_id())){
		    	prdInfoList1 = retPrdInfoDao.getShtListInfo(wipPrd.getBox_id());
			}
			oaryBList.add(oaryB);
			logger.info(wipEntry.getKey()+":"+ wipEntry.getValue());
		}
		outTrx.setOaryB(oaryBList);
		outTrx.setSum_cnt(oaryBList.size());
		outTrx.setRtn_code(RETURN_CODE_OK);
		outTrx.setRtn_mesg(RETURN_MESG_OK);
		return 0;
	}
}
